package cn.iocoder.yudao.module.api.shop.staff.vo;

import cn.iocoder.yudao.framework.validation.InEnumValue;
import cn.iocoder.yudao.module.api.shop.info.dto.ShopInfoDTO;
import cn.iocoder.yudao.module.api.shop.staff.enums.ShopStaffRoleEnum;
import cn.iocoder.yudao.module.api.shop.staff.enums.ShopStaffStatusEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;

@Schema(description = "店铺员工 Response VO")
@Data
public class ShopStaffVO {

    @Schema(description = "唯一编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17644")
    private Long id;

    @Schema(description = "店铺编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "26294")
    private Long shopId;

    @Schema(description = "店铺信息")
    private ShopInfoDTO shop;

    @Schema(description = "角色：0-普通店员、1-店长、2-核销员、3-配送员、4-收银员、5-业务员。多个之间用英文逗号隔开")
    @InEnumValue(ShopStaffRoleEnum.class)
    private List<Integer> roles;
    private String roleNames;

    @SuppressWarnings("unused")
    public String getRoleNames() {
        if (roleNames == null) {
            StringBuilder builder = new StringBuilder();
            for (int i = 0, n = roles.size(); i < n; i++) {
                if (i != 0) {
                    builder.append("、");
                }
                builder.append(ShopStaffRoleEnum.valueOf(roles.get(i)).getName());
            }
            roleNames = builder.toString();
        }
        return roleNames;
    }

    @Schema(description = "类型：0-空闲、1-忙碌、2-休息")
    @InEnumValue(ShopStaffStatusEnum.class)
    private Integer status;

    @SuppressWarnings("unused")
    public String getStatusName() {
        return ShopStaffStatusEnum.valueOf(getStatus()).getName();
    }

    @Schema(description = "负责人姓名", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
    private String contactName;

    @Schema(description = "负责人电话", requiredMode = Schema.RequiredMode.REQUIRED)
    private String contactMobile;

    @Schema(description = "前台用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25347")
    private Long memberUserId;

    @Schema(description = "后台用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22975")
    private Long adminUserId;

    @Schema(description = "最后一次送达时间")
    private LocalDateTime lastArrivedTime;

    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
    private LocalDateTime createTime;

}